import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        father: 23,
        son: "原始数据",
        num: 1
    },
    mutations: {
        changFather(state, payload) {
            state.father = payload.father
        },
        changnum(state, payload) {
            state.son = payload.son
        },
        changeSon(state, payload) {
            state.son = payload.son
        },
        change1(state, payload) {
            state.father = state.father + payload.num
        },
        changenum(state,payload){
           state.num = payload
        }
    },
    actions: {
        changeFather(context, payload) {
            let num =1
            let timer = setInterval(() => {
                num++
                context.commit("changenum",num)
                context.commit("change1", payload)
                if (num >= 60) {
                    clearInterval(timer)
                    num = 1
                    localStorage.setItem("father",23)
                    localStorage.setItem("time",1)
                }
                let absdioa=23
                localStorage.setItem("father", absdioa)
                localStorage.setItem("time", num)
            }, 1000)

        }
    },
    modules: {}
})
